﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class SellShipItem : CommodityBase
{
    public Text m_NameT;
    public Text m_PriceT;
    public Image m_Perview;

    public Ship Ship
    {
        set
        {
            if (null == value)
                return;
            m_CommodityShip = value;

            m_NameT.text = m_CommodityShip.m_ShipStruct.m_Name;
            m_PriceT.text = (m_CommodityShip.m_ShipStruct.m_Price/2f).ToString();
            m_Perview.sprite = m_CommodityShip.GetComponent<SpriteRenderer>().sprite;
            m_Perview.preserveAspect = true;
        }
        get { return m_CommodityShip; }
    }
    Ship m_CommodityShip;
    public void OnSellClicked()
    {
        Player.Instance.Money += m_CommodityShip.m_ShipStruct.m_Price / 2;
        Destroy(this.gameObject);

        Player.Instance.RemoveShip(m_CommodityShip);
        Player.Instance.save();
    }
    protected override void showDescritionPanel()
    {
        base.showDescritionPanel();
        if (m_DescriptionPanel == null)
            return;
        ShipDescriptionPanel panel = m_DescriptionPanel.GetComponent<ShipDescriptionPanel>();
        panel.Ship = m_CommodityShip as Ship;
    }
}
